package cn.gok;

public class Person {
    private String name;
    private String sex;
    private int age;
    private Boolean inMarried;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Boolean getInMarried() {
        return inMarried;
    }

    public void setInMarried(Boolean inMarried) {
        this.inMarried = inMarried;
    }

    public Person(String name, String sex, int age, Boolean inMarried) {
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.inMarried = inMarried;
    }

    public Person() {
    }

    public static boolean marryWith(Person p1, Person p2) {
        Person man = new Person();
        Person woman = new Person();
        if (p1.getInMarried().equals(false) && p2.getInMarried().equals(false)) {

            if (p1.getSex().equals("男")) {
                if (p2.getSex().equals("女")) {
                    man = p1;
                    woman = p2;
                }
            } else if (p2.getSex().equals("男")){
                if (p2.getSex().equals("女")) {
                    man = p2;
                    woman = p1;
                }
            }else{
                System.out.println("两人性别相同");
            }
            if(man.getAge()>20&&woman.getAge()>19){
                p1.setInMarried(true);
                p2.setInMarried(true);
                return true;
            }else {
                System.out.println("年龄不够");
            }
        } else {
            System.out.println("两人中有一人已婚");
        }
        return true;
    }

    public void study(String school){
        System.out.println(this.name+"在"+school+"学习");
    }


}
